import request from "@/utils/request";
import { praseStrEmpty } from "@/utils/harry";

// 跑腿员分页列表
export function listRunner(query) {
  return request({
    url: "/sys/runner/pageList",
    method: "get",
    params: query
  });
}
// 跑腿员详情
export function listRunnerDetails(userId) {
  return request({
    url: "/sys/runner/info/" + userId,
    method: "get"
  });
}
// 跑腿员下拉各种状态字典列表
export function runnerOption(query) {
  return request({
    url: "/sys/runner/pageList/select",
    method: "get",
    params: query
  });
}
// 新增平台跑腿员
export function addRunner(query) {
  return request({
    url: "/sys/runner/put",
    method: "put",
    data: query
  });
}

// 编辑平台跑腿员
export function editRunner(userId, query) {
  return request({
    url: "/sys/runner/put/" + userId,
    method: "put",
    data: query
  });
}

// 拉黑跑腿员
export function blackRunner(userId, query) {
  return request({
    url: "/sys/runner/pageList/black/" + userId,
    method: "put",
    data: query
  });
}
// 拉黑平台跑腿员
export function unBlackRunner(userId, query) {
  return request({
    url: "/sys/runner/pageList/black/un/" + userId,
    method: "put",
    data: query
  });
}
// 注销跑腿员
export function cancelRunner(userId, query) {
  return request({
    url: "/sys/runner/pageList/cancel/" + userId,
    method: "put",
    data: query
  });
}
// 解冻跑腿员
export function thawRunner(userId, query) {
  return request({
    url: "/sys/runner/pageList/thaw/" + userId,
    method: "put",
    data: query
  });
}

// 待审核跑腿员分页列表
export function listRunnerCheck(query) {
  return request({
    url: "/sys/runner/pageList/check",
    method: "get",
    params: query
  });
}

// 待审核跑腿员详情
export function listRunnerCheckDetails(userId) {
  return request({
    url: "/sys/runner/info/check/" + userId,
    method: "get"
  });
}
// 审核-跑腿员
export function checkRunner(userId, params) {
  return request({
    url: "/sys/runner/check/" + userId,
    method: "POST",
    data: params
  });
}

// 用户头像上传
export function uploadImg(data) {
  return request({
    url: "/applet/oss/upload",
    method: "post",
    data: data
  });
}

// 用户头像上传
export function getRunnerAreaList() {
  return request({
    url: "/sys/runner/put/select",
    method: "get"
  });
}

// 用户头像上传
export function changeRunnerArea({ id, schoolId }) {
  return request({
    url: `/sys/runner/put/${id}`,
    method: "put",
    data: {
      schoolId
    }
  });
}
// 上传图片 还没弄好
export function uploadImgold(query) {
  return request({
    url: "/oss/aliyun/policy",
    method: "get"
  }).then(res => {
    console.log("res+++++");
    console.log(res);
    console.log(query);
    let data = res.data;
    let file = query;
    let formData = new FormData();
    let imgType = file.type.split("/")[1];
    let filename = file.size + file.name;
    let keyValue = data.dir + "/" + filename;
    formData.append("key", keyValue);
    formData.append("policy", data.policy);
    formData.append("OSSAccessKeyId", data.accessKeyId);
    formData.append("success_action_status", 200);
    formData.append("signature", data.signature);
    formData.append("file", file, file.name);
    return request({
      url: data.host,
      method: "post",
      data: formData
    });
  });
}
/* accessKeyId: "LTAI4G3pqeCnQAqd6tvZ1Twg"
callback: "eyJjYWxsYmFja0JvZHlUeXBlIjoiYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkIiwiY2FsbGJhY2tVcmwiOiJodHRwOi8vaW1nLnRlY2gtaGFycnkuY24vYWxpeXVuL29zcy9jYWxsYmFjayIsImNhbGxiYWNrQm9keSI6ImZpbGVuYW1lPSR7b2JqZWN0fSZzaXplPSR7c2l6ZX0mbWltZVR5cGU9JHttaW1lVHlwZX0maGVpZ2h0PSR7aW1hZ2VJbmZvLmhlaWdodH0md2lkdGg9JHtpbWFnZUluZm8ud2lkdGh9In0="
dir: "harry/images/20211223"
host: "http://harry-run.oss-cn-zhangjiakou.aliyuncs.com"
policy: "eyJleHBpcmF0aW9uIjoiMjAyMS0xMi0yM1QwODoyNDoxMS4zODFaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjBdLFsic3RhcnRzLXdpdGgiLCIka2V5IiwiaGFycnkvaW1hZ2VzLzIwMjExMjIzIl1dfQ=="
signature: "rSdQgWVoiBa9ph2v0Ia8IDq4+gM="
 */
